package nc.ui.budget.tools.pubfun;

import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillEditEvent;
import nc.ui.trade.manage.BillManageUI;

public class UIAfterEdit {
	BillManageUI billUI;

	public UIAfterEdit(BillManageUI billUI) {
		this.billUI = billUI;
	}

	public void num_price_total(BillEditEvent arg0, String num, String price,
			String total) {
		BillCardPanel cardPanel = billUI.getBillCardPanel();

		if (arg0.getKey().equals(num) || arg0.getKey().equals(price)) {
			Object numObj = cardPanel.getBodyValueAt(arg0.getRow(), num);
			Object priceObj = cardPanel.getBodyValueAt(arg0.getRow(), price);
			if (numObj == null || priceObj == null) {
				cardPanel.setBodyValueAt(0, arg0.getRow(), total);
			} else {
				cardPanel.setBodyValueAt(Integer.parseInt(numObj.toString())
						* Double.parseDouble(priceObj.toString()), arg0
						.getRow(), total);
			}
		} else if (arg0.getKey().equals(total)) {
			cardPanel.setBodyValueAt(null, arg0.getRow(), num);
			cardPanel.setBodyValueAt(null, arg0.getRow(), price);
		}
	}
}
